import copy
# 字典

# 字典的创建
# 直接赋值
dict_01 = {'a':1,"b":2,'c':['111','222'],'d':{'aa':'a111'}}
# print(dict_01)
# dict()
dict_02 = dict(dict_01)
# print(dict_02)
dict_03 = dict([('a','1'),('b',2),('c',3)])
# print(dict_03)
dict_04 = dict(a = '222',b = '333',c = '444',d = '555')
# print(dict_04)
dict_05 = dict(zip(['a','b','c','d'],['111','112','113','114']))
# print(dict_05)
# fromkeys()
dict_06 = dict.fromkeys(['a','b','c','d'])
dict_07 = dict.fromkeys(['a','b','c','d'],1)
# print(dict_06)
# print(dict_07)
# print(dict_04['b'])
# print(dict_04.get('b'))
# print(dict_04.get('e',6))

# 常用操作
# 修改和添加
# print(dict_03)
# dict_03['a'] = 4
# print(dict_03)
# dict_03['d'] = 5
# print(dict_03)

# 删除
# print(dict_03)
# del dict_03['a']
# print(dict_03)
# dict_03.clear()
# print(dict_03)
# item = dict_03.pop("a","111")
# # dict_03.pop("a") # 不能这样写，会报错
# print(dict_03)
# print(item)
# print(dict_04)
# item_01 = dict_04.pop('a')
# print(dict_04)
# print(item_01)
# print(dict_04)
# item_02 = dict_04.popitem()
# print(dict_04)
# print(item_02)

# 更新
dict_08 = {'aa':'111','bb':'112','c':'113'}
# print(dict_08)
# print(dict_04)
# dict_04.update(dict_08)
# print(dict_04)

# 复制
# dict_09 = dict_08
# print(dict_09)
# dict_10 = dict_04.copy()
# print(dict_10)
# dict_11 = copy.deepcopy(dict_03)
# print(dict_11)

# 遍历字典
print(dict_03.items())
print(dict_03.keys())
print(dict_03.values())